﻿using System;
using System.Data;
using System.Text;

namespace msBsc.WebUi.Code
{
    public class mQtHtmlGet
    {
        //private msBsc.AppLogic.Cfg.UserInfo ouserinfo = new AppLogic.Cfg.UserInfo(); 
        public string GetHeaderLoginInfo()
        {
            StringBuilder sbRet = new StringBuilder();
            if (msBsc.SvRef.UserInfo.Online)
            {
                string userName = string.Empty;
                using (msBsc.AppLogic.DataAlc.CBizCustomerRegister objCBizCustomerRegister = new AppLogic.DataAlc.CBizCustomerRegister())
                {
                    DataSet ds = objCBizCustomerRegister.DataObj.QueryBySQL(@"SELECT A.CUSTOMER_NICK FROM DJK_CUSTOMER_REGISTER A WHERE CUSTOMER_REGISTER_ID='" + msBsc.SvRef.UserInfo.Operator + "'");

                    if (ds != null || ds.Tables[0].Rows.Count > 0)
                    {
                        userName = ds.Tables[0].Rows[0]["CUSTOMER_NICK"].ToString();
                    }
                }

                string personalLink = string.Empty;
                if (msBsc.SvRef.UserInfo.OperType == "1")
                {
                    personalLink = "/mb_UserInfo.htm";
                }
                else if (msBsc.SvRef.UserInfo.OperType == "2")
                {
                    personalLink = "/ms_UserInfo.htm";
                }

                sbRet.Append(@"<a href='" + personalLink + "' > " + userName + @"</a>  | <a href=""javascript:void(0);"" onclick=""$.setLoginOut();"" > 退出</a>  ");
            }
            else
            {
                sbRet.Append(@"<a href=""/mp_UserLogin.htm"" > 登录</a>  | <a href=""/mp_UserRegister.htm""  > 注册</a>  ");
            }
            return sbRet.ToString();
        }

        public string GetHeaderTopHtml(bool blGetLoginInfo, bool blShowGoodsClass = false)
        {
            string strtttt = "<div class=\"search-bar-cell-4\" > <a href=\"javascript:void(0);\" onclick=\"history.go(-1);\" style=\" vertical-align: middle; line-height: 28px; font-size: 16px;\">&lt;&lt;</a></div>";
            StringBuilder sbRet = new StringBuilder();
            sbRet.Append(@" 
    <header class=""search-bar"" style="" top:0px;""> 
    <form id=""J_shSearchForm"" method=""get"" action=""/m/mp_VehicleList.htm"">
        <div class=""search-bar-tbl"">
            <div class=""search-bar-cell-1""><a href=""javascript:void(0);""  ></a></div>
" + (blShowGoodsClass ? @"<div class=""search-bar-cell-3"" id=""GoodsClassBtn"">   <a href=""javascript:void(0);"" class=""menu"">分类</a> </div>" : "") + @"            
            <div class=""search-bar-cell-2"">
                <div class=""search-textfile"">
<a id=""searchbtn"" href=""javascript:void(0);"" onclick=""J_shSearchForm.submit();""  class=""btn-home-search"" ></a>
                    <input autocomplete=""off"" name=""f"" id=""f"" class=""search-textfile-input"" placeholder=""请输入地接客名称"">
                </div>
            </div>
<div class=""search-bar-cell-3"" id=""mymMallBtn""> 
                <a href=""javascript:void(0);"" class=""mymenu"">我的</a>
            </div>
        </div>
    </form> 
                <div class=""floor ""  id=""divmymMall"" style=""margin-bottom: 2px;margin-top: 2px; display:none;""> 
				<div class=""title-wrap"" style="" background-color:#fff; line-height:32px;  padding-left:10px;"" id=""divmyLoginInfo"">
" + (!blGetLoginInfo ? @"<a href=""/mp_UserLogin.htm"" > 登录</a>  | <a href=""/mp_UserRegister.htm""  > 注册</a> " : GetHeaderLoginInfo()) + @"  
                </div>
            </div>
 
    <script type=""text/javascript"">
        function initmymmall() {
            $(""#mymMallBtn"").click(function () {
                $(""#divmymMall"").toggle('fast');
            }); 
        };
        initmymmall();
    </script> 
 
</header>
");
            string menuItem = @"<ul class=""myMall-list"">
				                    <li class=""myMall-list-item"">
                <a href=""/mb_CustCart.htm"" class=""mymall-icon mycart""> 购物车</a> 
                    </li>
				                    <li class=""myMall-list-item""> 
                <a href=""javascript:void(0);"" class=""mymall-icon mycollGoods""> 收藏宝贝</a>  
                    </li>
				                    <li class=""myMall-list-item"">
                <a href=""/mb_ShopCollect.htm"" class=""mymall-icon mycollShop""> 收藏店铺</a>  
                    </li>
				                    <li class=""myMall-list-item"">
                <a href=""/mb_CustBought.htm"" class=""mymall-icon myallOrder""> 所有订单</a> 
                    </li>
				                </ul><%-- <div class=""search-bar-cell-3"" id=""mymMallBtn""> 
                <a href=""javascript:void(0);"" class=""mymenu"">我的</a>
            </div>--%>";
            //jQuery.loadHtml('/pgajax.axd?GETLOGIN_ST=1').done(function (_rets) { if (_rets != '0' && _rets != '') { ; }    });
            return sbRet.ToString();
        }

        public string getGoodsClassHtml()
        {
            StringBuilder sbRet = new StringBuilder();
            //System.Data.DataSet dst = null;
            //using (Epm.AppLogic.Framework.CDbAccess oCDbAccess = new Epm.AppLogic.Framework.CDbAccess())
            //{
            //    dst = oCDbAccess.QueryBySQL("SELECT LEVEL_ONE_ID,LEVEL_ONE_NME,SHOW_PAGE_URL,LEVEL_ONE_ICON FROM SHP_GOODS_TYPE_LEVEL_ONE ORDER BY SEQ_NUM");
            //}

            sbRet.Append(@"
<div class=""new-ct"" id=""divGoodsClass"" style=""display:none;"">
    <div class=""new-category"">
    <div style="" position:relative;left:0px;line-height:32px; background-color:#999;"">
    <div style="" position:absolute;left:0px;top:5px;"">
                <a href=""javascript:void(0);"" class=""menu""> </a>
    </div>
    <div class=""new-category-close"" style="" ""> 
      <span>× </span>
    </div>
    <div style="" position:relative;left:30px; color:#c40000;"">车型分类</div>

    </div>
    <div class=""clear""></div>
        <ul class=""new-category-lst"">");
            using (msBsc.AppLogic.DataAlc.CBizVehicleInfo vehicle = new AppLogic.DataAlc.CBizVehicleInfo())
            {
                DataTable dt = vehicle.GetVehicleType();
                foreach (System.Data.DataRow dr in dt.Rows)
                {
                    sbRet.Append(@"<li class=""new-category-li""><a href=""/mp_GoodsSearch.htm?c1=" + dr["enum_Value"].ToString() + @""" c1id=""" + dr["enum_Value"].ToString() + @""" class=""new-category-a""> <span class=""icon""></span>" + dr["enum_Name"].ToString() + "</a> </li>");
                }
            }
            //foreach (System.Data.DataRow dr in dst.Tables[0].Rows)
            //{
            //    sbRet.Append(@"<li class=""new-category-li""><a href=""/mp_GoodsSearch.htm?c1=" + dr["LEVEL_ONE_ID"].ToString() + @""" c1id=""" + dr["LEVEL_ONE_ID"].ToString() + @""" class=""new-category-a""> <span class=""icon""></span>" + dr["LEVEL_ONE_NME"].ToString() + "</a> </li>");
            //}
            sbRet.Append(@" 
        </ul>
    </div>
</div>

    <script type=""text/javascript"">
        function initcategory() {
            $(""#GoodsClassBtn"").click(function () {
                $(""#divGoodsClass"").toggle('fast');
            });
            $("".new-category-close"").click(function () {
                $(""#divGoodsClass"").hide('fast');
            });
        };
        initcategory();
    </script> 
     ");
            return sbRet.ToString();
        }

        public string GetFilterConditionHtml()
        {
            System.Text.StringBuilder resultHtml = new StringBuilder();
            resultHtml.Append("<ul class='filterTable'>");

            //添加国家信息
            resultHtml.Append("<li><div id='countryWrap'>" + GetAreaSelectString("00000000-0000-0000-0000-000000000000", "countrySel", false) + "</div></li>");

            resultHtml.Append("<li><div id='cityWrap'></div></li>");

            resultHtml.Append("<li><div id='desWrap'></div></li>");

            //添加车辆类型
            var vclType = Enum.GetValues(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleTypeEnum));

            if (vclType.Length > 0)
            {
                resultHtml.Append("<li><select id='vehicleType'><option selected='selected' value='0'>车型</option>");
                foreach (var item in vclType)
                {
                    resultHtml.Append("<option value=" + (int)item + ">" + item + "</option>");
                }
                resultHtml.Append("</select></li>");
            }

            //添加车辆品牌
            var vclBrand = Enum.GetValues(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleBrandEnum));

            if (vclBrand.Length > 0)
            {
                resultHtml.Append("<li><select id='vehicleBrand'><option selected='selected' value='0'>品牌</option>");
                foreach (var item in vclBrand)
                {
                    resultHtml.Append("<option value=" + (int)item + ">" + item + "</option>");
                }
                resultHtml.Append("</select></li>");

            }

            //添加价格
            resultHtml.Append("<li><select id='vehiclePrice'><option selected='selected' value='0|0'>价格</option>");
            resultHtml.Append("<option value='0|100'>￥100 以下</option>");
            resultHtml.Append("<option value='100|300'>￥100 - ￥300</option>");
            resultHtml.Append("<option value='300|600'>￥300 - ￥600</option>");
            resultHtml.Append("<option value='600|900'>￥600 - ￥900</option>");
            resultHtml.Append("<option value='900|1200'>￥900 - ￥1200</option>");
            resultHtml.Append("<option value='1200|1200'>￥1200 以上</option>");
            resultHtml.Append("</select></li>");

            //添加座位数选择
            resultHtml.Append("<li><select id='vehicleSeats'><option selected='selected' value='0|0'>座位</option>");
            resultHtml.Append("<option value='2|2'>2座</option>");
            resultHtml.Append("<option value='5|5'>5座</option>");
            resultHtml.Append("<option value='7|7'>7座</option>");
            resultHtml.Append("<option value='12|19'>12-19座</option>");
            resultHtml.Append("<option value='20|35'>20-35座</option>");
            resultHtml.Append("<option value='35|35'>35座以上</option>");
            resultHtml.Append("</select></li>");

            //添加服务类型
            var vclServiceType = Enum.GetValues(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.ServiceTypeEnum));

            if (vclServiceType.Length > 0)
            {
                resultHtml.Append("<li><select id='serviceType'><option selected='selected' value='0'>服务类型</option>");
                foreach (var item in vclServiceType)
                {
                    resultHtml.Append("<option value=" + (int)item + ">" + item + "</option>");
                }
                resultHtml.Append("</select></li>");

            }

            resultHtml.Append("</ul>");

            return resultHtml.ToString();
        }

        public string GetAreaSelectString(string parentId, string selectId, bool isContainAll)
        {
            DataSet ds;

            using (msBsc.AppLogic.DataAlc.CBizCountryCity objCBizCountryCity = new AppLogic.DataAlc.CBizCountryCity())
            {
                ds = objCBizCountryCity.SelectCountryByParentId(parentId);
            }

            System.Text.StringBuilder sbSelect = new StringBuilder();

            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                sbSelect.Append("<select id=" + selectId + ">");
                if (isContainAll)
                {
                    sbSelect.Append("<option value=>全部</option>");
                }
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    sbSelect.Append("<option value=" + ds.Tables[0].Rows[i]["COUNTRY_CITY_ID"].ToString() + ">" + ds.Tables[0].Rows[i]["COUNTRY_CITY_NME"].ToString() + "</option>");
                }
                sbSelect.Append("</select>");
            }
            return sbSelect.ToString();
        }

        public string GetScrollToTop()
        {
            string scrollTopHtml = @"<div class=""scrollToTop"" style=""position: fixed; right: 0; bottom: 200px; width: 20px; word-break: break-all; word-wrap: break-word; background-color: #808080; opacity: 0.8; display: none; cursor: pointer"">回顶部</div>";
            scrollTopHtml += @"<script type=""text/javascript"">
            var docScrollTop = 0;
            var interval;
            $(window).scroll(function () { showScrollTop(); })
            $("".scrollToTop"").click(function () {
                $(document).scrollTop(0);
            })
            function showScrollTop() {
                docScrollTop = $(document).scrollTop();
                if (docScrollTop >= 40) {
                    $("".scrollToTop"").fadeIn();
                } else {
                    $("".scrollToTop"").fadeOut();
                }
            }</script>";
            return scrollTopHtml;

            string a = @"interval = setInterval(function () {
                    if (docScrollTop >= 10) {
                        docScrollTop -= 10;
                        $(document).scrollTop(docScrollTop);
                    } else if (docScrollTop < 10) {
                        $(document).scrollTop(0);
                        clearInterval(interval);
                    }
                }, ""fast"");";
        }
    }
}